import { defineStore } from "pinia";
import { useLocalStorage } from "@vueuse/core";
import { ref } from "vue";

export const useCartListStore = defineStore("cartList", () => {
  const cartListLocalStorage = useLocalStorage("cart-list", []);
  const cartList = ref(cartListLocalStorage.value);
  function addToCartList(product) {
    cartList.value = [...cartList.value, product];
  }
  return {
    cartList,
    addToCartList,
  };
});
